<?php

namespace App\Console\Commands;

use App\Customer;
use App\Lead;
use App\Project;
use App\ProjectUser;
use Illuminate\Console\Command;
use function foo\func;

class CustomerTransfer extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'customer:tranfer';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $project_id=33;
        $user_id=[76,97];
        Lead::whereIn('owner_user_id',$user_id)->where('project_id',$project_id)->chunkById(100,function ($leads)use ($project_id){
           foreach ($leads as $item){
               $item->owner_user_id=56;
               $item->save();
             /*  if ($item->is_transform){
                  $customer= Customer::find($item->customer_id);
                  $customer->owner_user_id=48;

                  $customer->save();
               }*/
           }
        });
        Customer::whereIn('owner_user_id',$user_id)->where('project_id','=',$project_id)->chunkById(100,function ($customer)use ($project_id){
            foreach ($customer as $item){
                $project=  new ProjectUser();
                $item->owner_user_id=56;
                $item->save();
            }
        });
    }

}
